package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.mapper.TbBrandMapper;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author andy
* @description 针对表【tb_brand(品牌表)】的数据库操作Service实现
* @createDate 2025-07-21 15:23:46
*/
@Service
public class TbBrandServiceImpl extends ServiceImpl<TbBrandMapper, TbBrand>
    implements TbBrandService{

    @Autowired
    TbBrandMapper tbBrandMapper;

    @Override
    public R getBrandList(PageInfoVo pageInfoVo) {
        //--1 构造分页参数
        Page<TbBrand> page = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());

        //--2 获取分页数据
        Page<TbBrand> tbBrandPage = tbBrandMapper.selectPage(page,
                new QueryWrapper<TbBrand>().lambda().orderByDesc(TbBrand::getBrandId)
        );

        return R.OK(tbBrandPage);
    }

    @Override
    public R getBrandAll() {
        List<TbBrand> brandList = tbBrandMapper.selectList(null);
        return R.OK(brandList);
    }
}




